@model BarManager.UI.Web.Models.EmpleadoViewModel

@{ ViewBag.Title = "Empleado";}

@using (Html.BeginForm("Save", "Empleado"))
{
    @Html.AntiForgeryToken()

    <fieldset class="form-horizontal">
        <legend>Empleado</legend>

        @Html.HiddenFor(model => model.Entity.Id)

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.Nombre, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.Nombre)
                @Html.ValidationMessageFor(model => model.Entity.Nombre, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.Apellido, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.Apellido)
                @Html.ValidationMessageFor(model => model.Entity.Apellido, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.FechaAlta, new { @class = "control-label" })
            <div class="controls">
                @Html.DatePicker(Model.Entity.FechaAlta, "fechaAlta")
                @Html.ValidationMessageFor(model => model.Entity.FechaAlta, null, new { @class = "help-inline" })
                @Html.HiddenFor(model => model.Entity.FechaAlta)
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.FechaBaja, new { @class = "control-label" })
            <div class="controls">
                @Html.DatePicker(Model.Entity.FechaBaja, "fechaBaja")
                @Html.ValidationMessageFor(model => model.Entity.FechaBaja, null, new { @class = "help-inline" })
                @Html.HiddenFor(model => model.Entity.FechaBaja)
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.Email, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.Email)
                @Html.ValidationMessageFor(model => model.Entity.Email, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.Telefono1, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.Telefono1)
                @Html.ValidationMessageFor(model => model.Entity.Telefono1, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.Telefono2, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.Telefono2)
                @Html.ValidationMessageFor(model => model.Entity.Telefono2, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.RemuneracionPorHora, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.RemuneracionPorHora)
                @Html.ValidationMessageFor(model => model.Entity.RemuneracionPorHora, null, new { @class = "help-inline" })
            </div>
        </div>

        <div class="control-group">
            @Html.LabelFor(model => model.Entity.TieneComisionPorVenta, new { @class = "control-label" })
            <div class="controls">
                @Html.EditorFor(model => model.Entity.TieneComisionPorVenta)
                @Html.ValidationMessageFor(model => model.Entity.TieneComisionPorVenta, null, new { @class = "help-inline" })
            </div>
        </div>

        <div id="showPorcentaje">
            <div class="control-group">
                @Html.LabelFor(model => model.Entity.PorcentajeComision, new { @class = "control-label" })
                <div class="controls">
                    <div class="input-append">                        
                        @Html.TextBoxFor(model => model.Entity.PorcentajeComision, new { @class = "input-mini", @placeholder = "0,00" })                      
                        <span class="add-on">%</span>
                    </div>
                    @Html.ValidationMessageFor(model => model.Entity.PorcentajeComision, null, new { @class = "help-inline" })
                </div>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Cargo</label>
            <div class="controls">
                <div class="input-append">
                    @Html.DropDownListFor(model => model.Entity.CargoId, new SelectList(Model.Cargos, "Id", "Descripcion"), "Sin seleccionar", new { @class = "input-xlarge" })
                    @Html.ActionLink("Nuevo", "List", "Cargo", null, new { @class = "btn" });
                </div>
                @Html.ValidationMessageFor(model => model.Entity.CargoId, "Debe seleccionar un Cargo")
            </div>
        </div>

        <div class="control-group">
            <div class="controls">
                @Html.ValidationSummary(true)
            </div>
        </div>

        <div class="control-group">
            <div class="controls">
                <button id="savebutton" type="submit" class="btn btn-primary">Guardar</button>
                @Html.ActionLink("Cancelar", "List", null, new { @class = "btn" })
            </div>
        </div>
    </fieldset>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

    <script type="text/javascript">
        $(document).ready(function () {
            if ($("#Entity_TieneComisionPorVenta").is(':checked'))
                $("#showPorcentaje").show();
            else
                $("#showPorcentaje").hide();

            $("#Entity_TieneComisionPorVenta").click(function () {
                if ($(this).is(':checked'))
                    $("#showPorcentaje").show();
                else {
                    $("#showPorcentaje").hide();
                    $("#Entity_PorcentajeComision").val('');
                }
            });
        });

        $("#savebutton").click(function () {
            $("#Entity_FechaAlta").val($("#fechaAlta").val());
            $("#Entity_FechaBaja").val($("#fechaBaja").val());
        });
    </script>
}

